/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * <p>Project: app2022 - Exam06
 * <p>Powered by webrx On 2022-01-20 09:30:28
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Exam06 {
    public static void main(String[] args) throws IOException {
        var f1 = new FileInputStream("d:\\m1.wmv");
        var f2 = new FileInputStream("d:\\m2.wmv");
        var ok = new FileOutputStream("d:\\ok.wmv");
        ok.write(f1.readAllBytes());
        ok.write(f2.readAllBytes());
        ok.flush();
        ok.close();
    }

    public static void split(String[] args) throws IOException {
        String f = "d:\\m.wmv";
        File file = new File(f);
        //System.out.println(file.length());
        //FileInputStream fis = new FileInputStream(file);
        //System.out.println(fis.available());
        //System.out.println(fis.readAllBytes().length);
        long size = file.length();
        long a = size / 2;
        long b = size - a;
        byte[] buf = new byte[(int) a];
        FileInputStream fis = new FileInputStream(file);
        fis.read(buf);
        FileOutputStream out = new FileOutputStream("d:\\m1.wmv");
        out.write(buf);
        out.flush();
        out.close();

        byte[] buf2 = new byte[(int) b];
        fis.read(buf2);
        FileOutputStream out2 = new FileOutputStream("d:\\m2.wmv");
        out2.write(buf2);
        out2.flush();
        out2.close();

    }
}
